﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GraphPackage
{
    //  Stefan 21.11.2011
    /// <summary>
    /// Represents a vertex in a directed graph
    /// </summary>
    public class Vertex
    {
        private string _name;
        private bool _mark;
        private Object content;
        private IList<Edge> _edgeList;

        public Vertex(string name)
        {
            _mark = false;
            this._name = name;
            _edgeList = new List<Edge>();
            this.content = null;
        }

        public Vertex(String name, Object content)
            : this(name)
        {
            this.content = content;
        }

        public override string ToString()//For debugging purposes
        {
            return Name + "  " + Mark;
        }

        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        public bool Mark
        {
            get { return _mark; }
            set { _mark = value; }           
        }

        public Object Content
        {
            get { return content; }
            set { content = value; }
        }

        public IList<Edge> Edges() //must return a List in order to be able to remove edges
        {
            return _edgeList;
        }

        public void AddEdge(Vertex to)
        {
            Edge e = new Edge(this, to);
            _edgeList.Add(e);
        }

        public int OutDegree()
        {
            return _edgeList.Count;
        }

        public void RemoveEdge(Edge e)
        {
            _edgeList.Remove(e);
        }
    }
}
